<?php

class GalactusViewHelper {

	public function alertError($message = "Falha na realização da operação!", $url = URL) {
		$content = '
			<p class="lead text-error">'.$message.'</p>
			<script type="text/javascript">
				$(function( ) {
					$("#modal-error").modal( );
					$(".close").click(function( ) { location.href = "'.$url.'" });
				});
			</script>
		';
		$content = $this->modal("modal-error", '<span id="logo-galactus">GALACTUS</span>', $content);
		$content = $this->html($this->head( ).$this->body($content));
		echo $content;
	}

	public function alertSuccess($message = "Operação realizada com sucesso!", $url = URL) {
		$content = '
			<p class="lead">'.$message.'</p>
			<script type="text/javascript">
				$("#modal-success").modal( );
				$(".close").click(function( ) { location.href = "'.$url.'" });
			</script>
		';
		$content = $this->modal("modal-success", '<span id="logo-galactus">GALACTUS</span>', $content);
		$content = $this->html($this->head( ).$this->body($content));
		echo $content;
	}

	public function body($content) {
		return '<body>'.$content.'</body>';
	}

	public function head( ) {
		return '
			<head>
				<meta charset="utf-8">
				<title>Galactus</title>
				<meta name="viewport" content="width=device-width, initial-scale=1.0">
				<meta name="author" content="Thiago Medeiros de Menezes">
				<link href="http://fonts.googleapis.com/css?family=Coda+Caption:800" rel="stylesheet" type="text/css" />
				<link href="'.URL.'bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
				<link href="'.URL.'bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet" type="text/css" />
				<link href="'.URL.'RETRIEVE_CSS" rel="stylesheet" type="text/css" />
				<!--[if lt IE 9]>
				<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
				<![endif]-->
				<link rel="shortcut icon" href="images/galactus.png">
				<link rel="apple-touch-icon-precomposed" sizes="144x144" href="'.URL.'images/galactus.png">
				<link rel="apple-touch-icon-precomposed" sizes="114x114" href="'.URL.'images/galactus.png">
				<link rel="apple-touch-icon-precomposed" sizes="72x72" href="'.URL.'images/galactus.png">
				<link rel="apple-touch-icon-precomposed" href="'.URL.'images/galactus.png">
				<script type="text/javascript" src="'.URL.'jquery/jquery-1.9.1.min.js"></script>
				<script type="text/javascript" src="'.URL.'bootstrap/js/bootstrap.min.js"></script>
				<script type="text/javascript" src="'.URL.'RETRIEVE_JS"></script>
			</head>		
		';
	}

	public function html($content) {
		return '<!DOCTYPE html><html lang="pt">'.$content.'</html>';
	}

	public function modal($id, $title, $body, $footer = NULL) {
		$modal = '
			<div id="'.$id.'" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
					<h3 id="myModalLabel">'.$title.'</h3>
				</div>
				<div class="modal-body">'.$body.'</div>'
				.(!empty($footer)? '<div class="modal-footer">'.$footer.'</div>' : NULL).
			'</div>
		';
		return $modal;
	}

}
?>
